﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DAL
{
    public class RegionsDataModel
    {
        HomestayWebDBEntities ent = new HomestayWebDBEntities();
        public List<Region> SelectProvince()
        {
           
            return ent.Store_Region_SelectProvince().ToList();
        }
        public List<Region> SelectDistrict(int parentid)
        {
            return ent.Store_Region_SelectDistrict(parentid).ToList();

        }
        public string SelectNameFromID(int id)
        {
            string name = "";

            HomestayWebDBEntities ent = new HomestayWebDBEntities();
            var query = from em in ent.Regions
                        where em.RegionID == id
                        select em.Name;

            if (query != null)
            {
                List<string> list = query.ToList();
                if (list.Count > 0)
                {
                    name = list[0].ToString();
                }

            }
            return name;
        }

    }
}
